from django.shortcuts import render_to_response
from django.shortcuts import get_object_or_404
from django.template import RequestContext

from tppt.data.models import ProverProblemAnalysis

def get_ppa_problems(ppa):
	res=[]
	for grp in ppa.problem_groups.all():
		res.extend(grp.problems.all())
	return res

def show_ppa(request, object_id):
	ppa=get_object_or_404(ProverProblemAnalysis, pk=object_id)
	from tppt.data import analyzer
	problems = get_ppa_problems(ppa)
	provers = ppa.provers.all()
		
	results=analyzer.get_problem_prover_table(problems, provers)
	
	
	params={
		'problems': problems,
		'provers': provers,
		'results': results,
		'ppa': ppa
		}
	return render_to_response('data/ProverProblemAnalysis_detail.html', params, context_instance=RequestContext(request))